package com.gali.lovefinder.constant;

import com.gali.lovefinder.common.ErrorCode;
import com.gali.lovefinder.exception.BusinessException;
import lombok.Getter;

/**
 * MessageTypeEnum:
 *
 * @author gali
 * @date 2023/07/06
 */
@Getter
public enum MessageTypeEnum {
    EMAIL_MESSAGE("email", "邮件发送验证码"),
    PHONE_MESSAGE("phone", "手机发送验证码");

    private final String messageType;

    private final String message;

    MessageTypeEnum(String messageType, String message) {
        this.messageType = messageType;
        this.message = message;
    }

    /**
     * 获取枚举类
     * @param messageType
     * @return
     */
    public static MessageTypeEnum getMessageTypeEnum(String messageType) {
        for (MessageTypeEnum value : values()) {
            if (value.getMessageType().equals(messageType)) {
                return value;
            }
        }
        throw new BusinessException(ErrorCode.PARAMS_ERROR);
    }
}
